home *** CD-ROM | disk | FTP | other *** search
- //------------------------------------------------------------------------
- //-- Author: Jussi Jumppanen (jussij@ca.com.au)
- //-- Home Page: http://ourworld.compuserve.com/homepages/jussi
- //-- Usage: ZMI.EXE Zmi.zm
- //------------------------------------------------------------------------
-
- int TestMacro(void)
- {
- string strBuffer;
-
- //
- // This is a simple menu spawn written using the Zeus Macro language
- //
- while (1)
- {
- // Display a menu of option
- cls();
- printf("\n Zeus Macro Test Script ");
- printf("\n ---------------------- ");
- printf("\n 1) About the Zeus Interpreter ");
- printf("\n 2) View the source for this macro ");
- printf("\n 3) Spawn a system command test case");
- printf("\n 4) Loop test case ");
- printf("\n 5) String test case ");
- printf("\n 6) Quit macro\n ");
- printf("\n Input the required selection: ");
-
- get_number(sNumber);
-
- cls();
-
- // Process the item selected
- if (sNumber == 1)
- {
- printf("\n About the Zeus Interpreter ");
- printf("\n -------------------------- ");
- printf("\n This interpret implements a simple macro language that");
- printf("\n supports a small subset of the C language syntax. This");
- printf("\n test macro can be run using the ZMI.EXE intepreter and");
- printf("\n you can download the source, exe and document files for");
- printf("\n a cutdown version of the macro intepreter from the tools");
- printf("\n section the following home page:\n ");
- printf("\n http://ourworld.compuserve.com/homepages/jussi\n ");
- }
- else if (sNumber == 2)
- {
- printf("\n View the Source for This Macro ");
- printf("\n ------------------------------ ");
- printf("\n The source of this macro script is contained in the ");
- printf("\n file 'Zmi.zm'. The contents of this file will now ");
- printf("\n be displayed.\n ");
- printf("\n Hit any key to start the display.....\n ");
- getch();
-
- //-- build up the MS-DOS command
- strcpy(strBuffer, "more ");
- strcat(strBuffer, argv[1]);
- spawn(strBuffer);
- }
- else if (sNumber == 3)
- {
- printf("\n Spawn System Command Test Case ");
- printf("\n ------------------------------ ");
- printf("\n Input the command to run. If you are running an MS-DOS");
- printf("\n machine enter any DOS command (ie dir *.*) or enter");
- printf("\n the name of an MS-DOS application. If you are running");
- printf("\n Windows 95 or NT you can run MS-DOS commands or the name");
- printf("\n of a Windows applications like 'NOTEPAD.EXE'. ");
- printf("\n Enter the command to run: ");
- get_string(strBuffer);
- if (strlen(strBuffer))
- {
- printf("\n About to run the '%s' command.\n", strBuffer);
- printf("\n Hit any key to run the command.....\n");
- getch();
- spawn(strBuffer);
- }
- else
- {
- printf("\n No command was supplied!\n");
- }
- }
- else if (sNumber == 4)
- {
- printf("\n Loop Test Case ");
- printf("\n -------------- ");
- printf("\n This macro language supports the 'if', 'for' and 'while'");
- printf("\n control statements. Input the number of time you want");
- printf("\n the 'for' and 'while' loop test to run: ");
- get_string(strBuffer);
- sNumber = atoi(strBuffer);
-
- printf("\n Running 'For' Loop Test");
- for (i = 0; i < sNumber; ++i)
- {
- printf("\n For Loop Number: '%d'", i);
- }
-
- printf("\n\n Running 'While' Loop Test");
- i = 0;
- while (i < sNumber)
- {
- printf("\n While Loop Number: '%d'", i);
- ++i;
- }
-
- printf("\n");
- }
- else if (sNumber == 5)
- {
- printf("\n String Test Case ");
- printf("\n ---------------- ");
- printf("\n This macro language supports a string type as well");
- printf("\n the standard integer and char types.\n ");
- printf("\n Input any string text: ");
- get_string(strBuffer);
- printf("\n The string value you supplied was: '%s'\n", strBuffer);
- strupr(strBuffer);
- printf("\n The string value in upper case is: '%s'\n", strBuffer);
- strlwr(strBuffer);
- printf("\n The string value in lower case is: '%s'\n", strBuffer);
- sLength = strlen(strBuffer);
- printf("\n The string length is: '%d'\n", sLength);
- }
- else if (sNumber == 6)
- {
- // This quits the macro
- return 0;
- }
- else
- {
- printf("\n Unknown command entered!\n");
- }
-
- printf("\n Hit any key to continue.....");
- getch();
- }
- }
-
-